import {Type} from "@nestjs/common";

export class ObjectUtils {
    /**
     * 判断对象为空
     * @param o
     * @return
     */
    static isEmpty(o: object): boolean {
        if (!o || JSON.stringify(o) == "{}") {
            return true;
        }
        return false;
    }

    /**
     * 判断对象不为空
     * @param o
     */
    static isNotEmpty(o: any): boolean {
        return !this.isEmpty(o);
    }

    /**
     * 对象复制
     * @param source 源对象
     * @param target 赋值对象
     */
    static copyProperties<T>(source: any, target: any) {
        Object.keys(target).forEach(key => {
            if (source[key]) {
                target[key] = source[key];
            }
        })
        return target;
    }
}
